Any time we call process.nextTick() in a given phase, all callbacks passed to it will be resolved before the event loop continues. By using process.nextTick() we guarantee that the callback passed to it will always run after the current operation and before the event loop is allowed to proceed.
The nextTickQueue will be processed after the current operation is completed, regardless of the current phase of the event loop.
Here, an operation is defined as a transition from the underlying C/C++ handler, and handling the JavaScript that needs to be executed.
To achieve this, the JS call stack is allowed to unwind and then immediately execute the provided callback which allows a person to make recursive calls to process.nextTick() without reaching a RangeError: Maximum call stack size exceeded from v8.
By placing the callback in a process.nextTick(), the script still has the ability to run to completion, allowing all the variables, functions, etc., to be initialized prior to the callback being called. It also has the advantage of not allowing the event loop to continue. It may be useful for the user to be alerted to an error before the event loop is allowed to continue.